package com.itheima.io;

import java.io.File;
import java.util.HashMap;

public class Test3 {
    public static void main(String[] args) {
        File src = new File("day11");
        HashMap<String, Integer> map = new HashMap<>();
        getCount(map,src);
        System.out.println(map);
    }

    private static void getCount(HashMap<String, Integer> map, File src) {
        File[] files = src.listFiles();
        for (File file : files) {
            if (file.isFile()) {
                String[] split = file.getName().split("\\.");
                if (split.length == 2) {
                    String fileEndName = split[1];
                    if (map.containsKey(fileEndName)) {
                        map.put(fileEndName,map.get(fileEndName)+1);
                    }else {
                        map.put(fileEndName,1);
                    }
                }
            }else {
                getCount(map,file);
            }
        }
    }
}
